package cn.itsource.ymcc.factory;

import cn.itsource.ymcc.feignclient.CourseMarketFileFeignClient;
import cn.itsource.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class CourseMarketFallbackFactory implements FallbackFactory<CourseMarketFileFeignClient> {

    @Override
    public CourseMarketFileFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new CourseMarketFileFeignClient() {
            @Override
            public JSONResult get(Long id) {
                log.info("查询课程营销数据，异常");
                return JSONResult.error(id+"查询失败！");
            }
        };
    }
}
